package pl.edu.amu.wmi.kino.visualjavafx.model.animation.interpolators;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;


// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.7FEF5F2C-F856-92BB-BD84-5D381FB702C6]
// </editor-fold> 
public class Linear implements Interpolation ,java.io.Serializable{

    // Code block for changeListeners support start
    protected PropertyChangeSupport propertySupport= new PropertyChangeSupport(this);
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }
    // Code block for changeListeners support end

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.0F71327C-496E-492B-9B2B-AA721B920068]
    // </editor-fold> 
    public Linear () {
    }

    /**
     *  <html>
     *    <head>
     *  
     *    </head>
     *    <body>
     *      <p style="margin-top: 0">
     *    returns value between startVal and endVal after completing howMuch of it 
     *    - if howMuch is greater than 1 - it treats it as if it would be 1.
     *      </p>
     *    </body>
     *  </html>
     */
    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.E850F312-9D93-D83D-7D7C-C51BA62A6107]
    // </editor-fold> 
    @Override
    public double getValue (double howMuch, double startVal, double endVal) {
        if(howMuch>=0)
            return startVal+(endVal-startVal)*howMuch;
        else throw new ArithmeticException();
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.E037BDE9-8B48-5C51-7B48-68AE6F9BB1DA]
    // </editor-fold> 
    @Override
    public double getValueAtTime (double howMuch, double Time, double startVal, double endVal) {
        return this.getValue(howMuch, startVal, endVal);
    }

    @Override
    public String getName() {
        return this.name;
    }


    private String name="LINEAR";

}

